<?php

require_once 'constants.php';

abstract class Buffalo_Taxonomy {

    private $taxonomy_name;
    private $object_type;

    function __construct($taxonomy_name, $object_type) {
        $this->taxonomy_name = $taxonomy_name;
        $this->object_type = $object_type;
        add_action('init', array(&$this, 'register_taxonomy'));
    }

    function register_taxonomy() {
        $args = $this->get_args();
        register_taxonomy($this->taxonomy_name, $this->object_type, $args);
    }

    protected function get_labels($singular, $plural = '') {
        if (empty($plural)) {
            $plural = $singular . 's';
        }

        $labels = array(
            'name' => _x($plural, 'taxonomy general name'),
            'singular_name' => _x($singular, 'taxonomy singular name'),
            'search_items' => __('Search ' . $plural),
            'popular_items' => __('Popular ' . $plural),
            'all_items' => __('All ' . $plural),
            'parent_item' => __('Parent ' . $singular),
            'parent_item_colon' => __('Parent ' . $singular . ':'),
            'edit_item' => __('Edit ' . $singular),
            'update_item' => __('Update ' . $singular),
            'add_new_item' => __('Add New ' . $singular),
            'new_item_name' => __('New ' . $singular . ' Name')
        );

        return $labels;
    }

    protected abstract function get_args();
}

class Category_Taxonomy extends Buffalo_Taxonomy {

    function __construct() {
        parent::__construct(CATEGORY_TAXONOMY, PRODUCT_POST_TYPE);
    }

    protected function get_args() {
        return array(
            'label' => __('Categories'),
            'labels' => $this->get_labels('Category', 'Categories'),
            'hierarchical' => true,
            'query_var' => true
        );
    }

}

?>
